﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PPI.Entities.Base;
using PPI.Entities.Inspections;

namespace PPI.Entities.Remedy
{
    public class ERemedy : EGoogleEarth
    {
        private Int32 m_Id;
        private string m_notes;
        private DateTime m_resolvedDate;
        private DateTime m_lastAction;
        private string m_assigned;
        private ERemedyStatus m_status;
        private EInspection m_Inspection;

        #region Properties

        public string Notes
        {
            get { return m_notes; }
            set { m_notes = value; }
        }

        public DateTime ResolvedDate
        {
            get { return m_resolvedDate; }
            set { m_resolvedDate = value; }
        }

        public DateTime LastAction
        {
            get { return m_lastAction; }
            set { m_lastAction = value; }
        }

        public string Assigned
        {
            get { return m_assigned; }
            set { m_assigned = value; }
        }

        public ERemedyStatus Status
        {
            get { return m_status; }
            set { m_status = value; }
        }

        public EInspection Inspection
        {
            get { return m_Inspection; }
            set { m_Inspection = value; }
        }

        public int Id
        {
            get { return m_Id; }
            set { m_Id = value; }
        }

        #endregion

        public ERemedy()
        {
            m_Id = Int32.MinValue;
            m_Inspection = new EInspection();
            m_status = new ERemedyStatus();
            m_assigned = "";
            m_lastAction = DateTime.MinValue;
            m_resolvedDate = DateTime.MinValue;
            m_notes = "";
        }

        protected override string GetPositionKML()
        {
            StringBuilder s = new StringBuilder();
            s.AppendLine("<Point id=\"" + GetPlacemarkId() + "\">");
            s.AppendLine("  <coordinates>" + this.Inspection.Longitude.ToString().Replace(",", ".") + "," + this.Inspection.Latitude.ToString().Replace(",", ".") + " ,1500</coordinates>");
            s.AppendLine("</Point>");
            return s.ToString();
        }

        public override string GetPlacemarkId()
        {
            return String.Format("Remedy_{0}", this.Id);
        }

        public override string GetHtmlPlacemark()
        {
            return this.Inspection.GetHtmlPlacemark();
        }

        public override string GetIcon()
        {
            return this.Inspection.GetIcon();
        }

        public override string GetHtmlName()
        {
            return string.Format("Remedy {0}",Id);
        }
    }
}
